home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 November / SGI Freeware 1999 November - Disc 2.iso / relnotes / shared / mkindex.sh < prev   
Text File  |  1999-10-18  |  4KB  |  152 lines

  1. #!/sbin/sh
  2. #
  3. # Create an HTML index from the installed Freeware products based
  4. # on the release notes.
  5. #
  6. # usage: $0 [-installed|-web]
  7. # -installed     create index.html and index for installed products.
  8. # -web            create web pages (i.e. leave out installed.html)
  9. # -web is designed for internal SGI use only; generate pages for silicon surf.
  10. #
  11. # -installed is the default
  12. #
  13. # input: $COMMON/index.template
  14. # output: $RELDIR/index.html, $RELDIR/installed.html
  15. #
  16.  
  17. RELDIR=${rbase:=/}/usr/freeware/relnotes
  18. COMMON=$RELDIR/shared  ## MUST NOT CHANGE. same location as old fw_common
  19.  
  20. INDEX=$RELDIR/index.html
  21. INST=$RELDIR/installed.html
  22. TMP=/tmp/mkindex.$$
  23.  
  24. INST_ED="INSTALLED INDEX"
  25. INST_ABLE="INSTALLABLE INDEX"
  26. HTTP_LINK="HTTP LINKS"
  27.  
  28.  
  29. ################
  30. ## subroutines
  31.  
  32. rminsted()
  33. { # rminsted $input_file
  34.     # create index.html
  35.     sed -e "/<!-- BEGIN $INST_ED -->/,/<!-- END $INST_ED -->/d" <$1 >$TMP
  36.     mv -f $TMP $1
  37. }
  38.  
  39. rminstable()
  40. { # rminstable $input_file
  41.     # create index.html
  42.     # remove INSTALLABLE portion if not available
  43.     if [ ! -f $RELDIR/index-by-alpha.html ]
  44.         then  ## fw_latest is not available
  45.         sed -e "/<!-- BEGIN $INST_ABLE -->/,/<!-- END $INST_ABLE -->/d" <$1 >$TMP
  46.         mv -f $TMP $1
  47.     #else
  48.         #nop
  49.         fi
  50. }
  51.  
  52. rmhttplink()
  53. { # rmhttplink $input_file
  54.     # create index.html
  55.     sed -e "/<!-- BEGIN $HTTP_LINK -->/,/<!-- END $HTTP_LINK -->/d" <$1 >$TMP
  56.     mv -f $TMP $1
  57. }
  58.  
  59. makeinstalled()
  60. { # makeinstalled $input_file
  61.     cat >$1 <<_EOINDEX_
  62.     <HTML>
  63.     <HEAD>
  64.     <TITLE>Installed products</TITLE>
  65.     </HEAD>
  66.     <BODY bgcolor=white>
  67.     <H2>Product Listing</H2>
  68.     <UL>
  69. _EOINDEX_
  70.  
  71.     # Parse each release note and add a entry.  The entry will consist
  72.     # of the title as represented in the <TITLE> identifier and a link
  73.     # to the actual release note
  74.     # first egrep -v is for files created by fw_common
  75.     # second egrep -v is for files created by fw_latest
  76.     # third egrep is to remove empty lines
  77.     #
  78.     # awk '{ for(i=1;i<=NF;i++){print $i;} }' = fmt -1
  79.     for FILE in `cd $RELDIR && \
  80.         echo *.html | awk '{ for(i=1;i<=NF;i++){print $i;} }' | \
  81.         egrep -v "(installed|index).html" | \
  82.         egrep -v "index-(by-alpha|by-category|by-date|alt).html" | \
  83.         egrep -v "^$" `
  84.     do
  85.         # sed -e 1q == head -1
  86.         # sed -e 's/.*>\(.*\)>.*/\1/' == cut -f2- -d'>' | cut -f1 -d'<'
  87.         #    to get the parts between <title>(I WANT THIS PART)</title>
  88.         TITLE=`grep -i '<TITLE>' $RELDIR/$FILE | \
  89.             sed -e '1q' | \
  90.             sed -e 's/.*>\(.*\)<.*/\1/' `
  91.         echo "<LI><A HREF=\"$FILE\">$TITLE</A>"        >>$1
  92.     done
  93.     
  94.     # Create the footer information
  95.     cat >>$1 <<_EOINDEX_
  96. </UL>
  97.     
  98. <BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
  99. <BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
  100. <BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
  101.     
  102. </BODY>
  103. </HTML>
  104. _EOINDEX_
  105. }
  106.  
  107. ## subroutines
  108. ################
  109.  
  110. # parse command line option
  111. # default to -installed
  112. if [ "$1" = '' ] ; then MODE=-installed 
  113. else MODE=$1 ; fi
  114.  
  115. # default is to remove all index.html link sections
  116. RMINSTED=true
  117. RMINSTABLE=true
  118. RMHTTPLINK=true
  119. # default is to create only the index.html file
  120. INSTABLE=false
  121. # set command line option
  122. case $MODE in 
  123.     -installed)  ## default
  124.         RMINSTED=false
  125.         INSTABLE=true
  126.         RMHTTPLINK=false
  127.         ;;
  128.     -web)
  129.         echo "                                       WEB"
  130.         RMINSTABLE=false
  131.         ;;
  132.     esac
  133. RMINSTED="[ true = $RMINSTED ]"
  134. RMINSTABLE="[ true = $RMINSTABLE ]"
  135. RMHTTPLINK="[ true = $RMHTTPLINK ]"
  136. INSTABLE="[ true = $INSTABLE ]"
  137. # init
  138.  
  139. # Remove the previous index if one exists
  140. # Create the index.html ($INDEX)
  141. rm -f $INDEX
  142. cp $COMMON/index.template $TMP.start
  143. $RMINSTED   && rminsted   $TMP.start
  144. $RMINSTABLE && rminstable $TMP.start
  145. $RMHTTPLINK && rmhttplink $TMP.start
  146. mv -f $TMP.start $INDEX
  147.  
  148. # create installed.html ($INST)
  149. $INSTABLE && makeinstalled $INST
  150.  
  151. exit 0
  152.